package com.yanqu.road.server.manager.tomb.service;

import com.google.protobuf.AbstractMessage;
import com.google.protobuf.InvalidProtocolBufferException;
import com.yanqu.road.pb.syncMessage.SyncMessage;
import com.yanqu.road.pb.tomb.Tomb;
import com.yanqu.road.server.command.ICrossServiceCommand;
import com.yanqu.road.server.manager.tomb.TombServiceMgr;

import java.util.concurrent.CompletableFuture;


public class TombRepairCmd implements ICrossServiceCommand {
    @Override
    public CompletableFuture<AbstractMessage.Builder<?>> execute(SyncMessage.Request request, int activityId, int groupId) throws InvalidProtocolBufferException {
        Tomb.TombRepairReq req= Tomb.TombRepairReq.parseFrom(request.getDataBytes());
        int oneKey = req.getOneKey();
        long useItemNum = req.getUseItemNum();
        long userId = request.getSenderId();
        //int activityId = request.getActivityId();
        String unionUid = req.getUnionUid();
        Tomb.TombRepairResp.Builder respBuilder = TombServiceMgr.tombRepair(oneKey, useItemNum, userId, activityId,unionUid);
        CompletableFuture<AbstractMessage.Builder<?>> completableFuture = new CompletableFuture<>();
        completableFuture.complete(respBuilder);
        return completableFuture;
    }
}
